// 导入路由包
import { createRouter, createWebHashHistory } from 'vue-router'
// 导入要使用的组件
import Home from './MyHome.vue'
import Movie from './MyMovie.vue'
import About from './MyAbout.vue'
import Tab1 from './Tab1.vue'
import Tab2 from './Tab2.vue'
// 创建实例对象
const router = createRouter({
    //指定history路由的工作模式
    history: createWebHashHistory(),
    linkActiveClass: 'router-active',
    routes: [
        { path: '/', redirect: '/home' },
        { path: '/home', component: Home },
        { name: 'mov', path: '/movie/:id', component: Movie, props: true },
        {
            path: '/about',
            component: About,
            redirect: '/about/tab1',
            children: [
                { path: 'tab1', component: Tab1 },
                { path: 'tab2', component: Tab2 }
            ]
        }
    ]
})

//声明全局的导航守卫
router.beforeEach((to, from) => {
        // console.log('ok');
        // console.log(to);打印去到的那个组件的消息
        // console.log(from);打印从哪个页面来的组件消息
    })
    // 向外导出模块
export default router